import json

import seaborn as sns
import matplotlib.pyplot as plt


plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签SimHei
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号

path = r'D:\桌面\fsdownload\res\json\confusion_matrix.json'

with open(path, 'r', encoding='utf-8') as fp:
    confusion_matrix = json.load(fp)

# 创建标签
labels = ['持', '制', '买卖', '不相关']

# 使用seaborn绘制热图
plt.figure(figsize=(10, 7))
sns.heatmap(confusion_matrix, annot=True, fmt='d', cmap='Oranges', xticklabels=labels, yticklabels=labels)
plt.xlabel('Predicted Label')
plt.ylabel('True Label')
plt.savefig(r'D:\桌面\fsdownload\res\picture\confusion_matrix.png')

